package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.logic.activity.evefeast.EveFeastConfig;
import com.yanqu.road.logic.activity.silkroad.SilkRoadConfig;
import com.yanqu.road.server.manger.activity.evefeast.EveFeastMgr;
import com.yanqu.road.server.manger.activity.silkroad.SilkRoadMgr;

import java.util.ArrayList;

public class EveFeastRecycleStrategy extends AbstractItemRecycleStrategy {

    @Override
    public void markNeedRecycleItem() {
        EveFeastConfig config = EveFeastMgr.getConfig();
        ActivityInfo activityInfo = EveFeastMgr.getActivityInfo();
        if (config != null && activityInfo != null) {
            for (Integer itemId : config.getRecycleItemList()) {
                long recycleTime = activityInfo.getEndShowTime() * 1000L + 600 * 1000;
                ActivityItemRecycleMgr.addRecycleItemData(itemId, activityInfo.getType(), 2, recycleTime, new ArrayList<>());
            }
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.EveFeast.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {

        if (data.getRecycleType() == 2) {
            UserBagItem userBagItem = getUserBagItem(userId, data.getItemId());
            if (userBagItem != null && userBagItem.getNum() > 0) {
                removeItem(userBagItem);
            }
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
